package com.ronsai.umtrack.api.interceptor;

import com.ronsai.umtrack.MyApp;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 拦截器：添加请求头
 */
public class HttpHeaderInterceptor implements Interceptor {

    private static final String USER_TOKEN = "Authorization"; //token的键一般是Authorization

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request().newBuilder()
                .header(USER_TOKEN, MyApp.getToken())
                .build();
        return chain.proceed(request);
    }
}
